function checkUser1(response){
    var obj=JSON.parse(response);
    if("exist"==obj){
        alert("用户已存在");
        window.location.href = path+"/regisiter1.jsp";
    }
    if("success"==obj){
        window.location.href = path+"/login.jsp";
    }
    if(obj=="success"){
        var newEmail=document.getElementById("email").value;
        ajaxCall("POST",path+"/BoolServlet?method=sendEmail&newEmail="+newEmail,loginSend);
    }
}
function loginSend(response){
    var obj=JSON.parse(response);
    alert(obj);
}

function init(){
    ajaxCall("POST",path+"/BoolServlet?method=searchClazz",initClazz);
}
function initClazz(res){
    var obj=JSON.parse(res);
    for(var i in obj){
        var sClazz=document.getElementById("selectclazz")
        sClazz.options.add(new Option(obj[i].name,obj[i].id));
    }
}
function checkUser(){
    var name=document.getElementById("username").value;
    var password=document.getElementById("password").value;
    var confirmPassword=document.getElementById("confirmPassword").value;
    var email=document.getElementById("email").value;
    var type="student";
    var clazzID=document.getElementById("selectclazz").value;
    var password1=document.getElementById("password").value;
    var myReg=/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/;//查看邮箱格式是否正确
    if(!myReg.test(email)){
        alert("邮箱格式不对!");
        return;
    }if(name==null||name==""||password==null||password==""||confirmPassword==null||confirmPassword==""||
        email==null||email==""){
        alert("你还有东西没有填写完毕！");
        return;
    }if(password1!=confirmPassword){
        alert("密码错误！");
        return;
    }if(password1==confirmPassword){
        ajaxCall("POST",path+"/BoolServlet?method=boolUser&name="+name+"&password="+password+"&clazzId="+
            clazzID+"&email="+email+"&type="+type ,checkUser1);
    }
}